/**
 * 
 * Code contributed by IUP Research Institute
 * 
 *     This file is part of NetworkMon.
 *
 *   NetworkMon is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; version 2 of the License.
 *
 *   NetworkMon is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with NetworkMon; if not, write to the Free Software
 *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
package networkbackend;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * 
 * @author fkern
 */
@SuppressWarnings("serial")
public class AddressLinkedList extends LinkedList<Object> {

	/** Creates a new instance of AddressLinkedList */
	public AddressLinkedList() {

	}

	public String[] GetAddresses() {
		String[] retval = null;

		synchronized (this) {

			retval = new String[this.size()];

			Iterator<?> iterator = this.iterator();
			AddressNode currentNode = new AddressNode();
			currentNode.totalReceivedLifetimeBytes = 0;

			while (iterator.hasNext()) {

				currentNode = (AddressNode) iterator.next();

			}

		}

		return retval;
	}

	public int indexOf(String label) {
		int retval = -1;
		int count = 0;

		AddressNode currentNode = null;

		Iterator<Object> iterator = this.iterator();

		while (iterator.hasNext()) {

			currentNode = (AddressNode) iterator.next();

			if (currentNode != null) {
				if (currentNode.address.equals(label) == true) {
					retval = count;
					break;
				}
			}
			count++;
		}

		return retval;
	}

}
